package com.xd.hbsys.common;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.jdbc.core.JdbcTemplate;


@Configuration
public class DBConfig {

    @Bean(name = "hbDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.hb")
    public DataSource hbDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "hbJdbcTemplate")
    public JdbcTemplate hbJdbcTemplate(@Qualifier("hbDataSource") DataSource dsmy) {
        return new JdbcTemplate(dsmy);
    }
}
